package com.ddw.meedeeuh.shared.movie.scrapers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public abstract class SearchMovieScraperResultFactory {

	private static final List<SearchMovieResult> EMPTY = Collections.unmodifiableList(new ArrayList<SearchMovieResult>());

	public static SearchMovieScraperResult create(MovieScraperResultType type) {
		return new MovieScraperResultImpl(type, EMPTY);
	}

	public static SearchMovieScraperResult create(MovieScraperResultType type, List<SearchMovieResult> movies) {
		if(type == null) {
			throw new IllegalArgumentException("The result type cannot be null");
		}
		if(movies == null) {
			throw new IllegalArgumentException("The list of movies cannot be null");
		}

		return new MovieScraperResultImpl(type, movies);
	}

	private static class MovieScraperResultImpl implements SearchMovieScraperResult {

		private final MovieScraperResultType type;
		private final List<SearchMovieResult> movies;

		public MovieScraperResultImpl(MovieScraperResultType type, List<SearchMovieResult> movies) {
			this.type = type;
			this.movies = movies;
		}

		@Override
		public MovieScraperResultType getResult() {
			return this.type;
		}

		@Override
		public List<SearchMovieResult> getMovies() {
			return this.movies;
		}

	}

}
